import React from 'react';
import {
  AsyncStorage,
} from 'react-native';

import Config from '../config';
import Constants from '../common/Constants';
import BaseModel from './BaseModel';

export default class VipSerCardModel extends BaseModel {
  constructor() {
    super();

    this.moduleType = Constants.MODULE_TYPE.VIPSERCARD;
    this.requestList = this.requestList.bind(this);
    this.requestActContent = this.requestActContent.bind(this);
    this.createSuggest = this.createSuggest.bind(this);
  }

  requestList(data, callback){
    //boards?page=1&page_size=10&sort_id=1&type=4
    var url = Config.serverUrl + '/boards/2/posts?page=' + data.page + '&page_size=' + data.page_size + '&sort_id=' + data.sort_id + '&tag=' +data.tag ;
    this.sendGet(url,callback);
  }

  requestActContent(data, callback){
    var url = Config.serverUrl + '/boards/2/posts/' + data.post_id;
    this.sendGet(url, callback);
  }

  //推荐商家
  createSuggest(data, callback) {
    var sendData = {
      payload: {
        "name": data.name,
        "cardno": data.cardno,
        "business_type": data.business_type,
        "business_contact_way": data.business_contact_way,
        "business_contact_person": data.business_contact_person,
        "business_address": data.business_address,
      }
    }
    this.sendPost(Config.serverUrl + '/preference/businesses', JSON.stringify(sendData), callback);
  }

}
